package com.hdd.art.biz;
import com.hdd.art.config.Constant;
import com.hdd.art.dto.AppResponse;
import com.qiniu.util.Auth;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

/**
 * @author fang
 * @date 2019/10/15 18:09
 **/
@CrossOrigin(maxAge = 3600)
@RestController
@Api(value = "后台-七牛相关接口" ,description ="后台-七牛相关接口")
@RequestMapping("/upload")
public class QiniuController {

    private Auth auth = null;

    @ResponseBody
    @ApiOperation(value="获取后台图片上传token √", notes="")
    @RequestMapping(value = "/getUploadToken", method = RequestMethod.POST)
    public AppResponse getWebUploadToken() {
        AppResponse response = new AppResponse();
        auth = Auth.create(Constant.ACCESS_KEY, Constant.SECRET_KEY);
        response.setToken(auth.uploadToken(Constant.bucket_web));
        return response;
    }

}
